{
unsigned long test = BYTEORDER_TEST;
- unsigned char* ptr = (unsigned char*)(&test);
+ auto* ptr = (unsigned char*)(&test);
unsigned int order = (ptr[0] << 12) | (ptr[1] << 8) | (ptr[2] << 4) | ptr[3];
return order;
static void sw_bytes(void* word)
{
- uint8_t* p = (uint8_t*) word;
- uint16_t* r = (uint16_t*) word;
+ auto* p = (uint8_t*) word;
+ auto* r = (uint16_t*) word;
*r = (uint16_t)(p[1] << 8 | p[0]);
}
static void sw_words(void* dword)
{
- uint16_t* p = (uint16_t*) dword;
- uint32_t* r = (uint32_t*) dword;
+ auto* p = (uint16_t*) dword;
+ auto* r = (uint32_t*) dword;
*r = (uint32_t)(p[0] << 16 | p[1]);
}
static void rev_bytes(void* dword)
{
- uint8_t* p = (uint8_t*) dword;
- uint32_t* r = (uint32_t*) dword;
+ auto* p = (uint8_t*) dword;
+ auto* r = (uint32_t*) dword;
*r = (uint32_t)(p[3] << 24 | p[2] << 16 | p[1] << 8 | p[0]);
}
static void Destroy_AN1_Waypoint(void* vwpt)
{
- an1_waypoint_record* wpt = (an1_waypoint_record*)vwpt;
+ auto* wpt = (an1_waypoint_record*)vwpt;
xfree(wpt->name);
xfree(wpt->fontname);
static void Copy_AN1_Waypoint(void** vdwpt, void* vwpt)
{
- an1_waypoint_record* wpt = (an1_waypoint_record*)vwpt;
+ auto* wpt = (an1_waypoint_record*)vwpt;
an1_waypoint_record* dwpt = Alloc_AN1_Waypoint();
memcpy(dwpt, wpt, sizeof(an1_waypoint_record));
dwpt->name = xstrdup(wpt->name);
static an1_waypoint_record* Alloc_AN1_Waypoint()
{
- an1_waypoint_record* result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1);
+ auto* result = (an1_waypoint_record*)xcalloc(1, sizeof(an1_waypoint_record));
result->fs.type = FS_AN1W;
result->fs.copy = Copy_AN1_Waypoint;
result->fs.destroy = Destroy_AN1_Waypoint;
static void Copy_AN1_Vertex(void** vdvert, void* vvert)
{
- an1_vertex_record* vert = (an1_vertex_record*)vvert;
+ auto* vert = (an1_vertex_record*)vvert;
an1_vertex_record* dvert = Alloc_AN1_Vertex();
memcpy(dvert, vert, sizeof(an1_vertex_record));
*vdvert = (void*)dvert;
static an1_vertex_record* Alloc_AN1_Vertex()
{
- an1_vertex_record* result = (an1_vertex_record*)xcalloc(sizeof(*result), 1);
+ auto* result = (an1_vertex_record*)xcalloc(1, sizeof(an1_vertex_record));
result->fs.type = FS_AN1V;
result->fs.copy = Copy_AN1_Vertex;
result->fs.destroy = Destroy_AN1_Vertex;
static void Destroy_AN1_Line(void* vline)
{
- an1_line_record* line = (an1_line_record*)vline;
+ auto* line = (an1_line_record*)vline;
xfree(line->name);
xfree(vline);
}
static void Copy_AN1_Line(void** vdline, void* vline)
{
- an1_line_record* line = (an1_line_record*)vline;
+ auto* line = (an1_line_record*)vline;
an1_line_record* dline = Alloc_AN1_Line();
memcpy(dline, line, sizeof(an1_line_record));
dline->name = xstrdup(line->name);
static an1_line_record* Alloc_AN1_Line()
{
- an1_line_record* result = (an1_line_record*)xcalloc(sizeof(*result), 1);
+ auto* result = (an1_line_record*)xcalloc(1, sizeof(an1_line_record));
result->fs.type = FS_AN1L;
result->fs.copy = Copy_AN1_Line;
result->fs.destroy = Destroy_AN1_Line;
unsigned removed = 0;
foreach (Waypoint* wp, *global_waypoint_list) {
- extra_data* ed = (extra_data*) wp->extra_data;
+ auto* ed = (extra_data*) wp->extra_data;
wp->extra_data = nullptr;
if (ed) {
if ((ed->distance >= pos_dist) == (exclopt == nullptr)) {
int
cet_utf8_to_ucs4(const char* str, int* bytes, int* value)
{
- unsigned char* cp = (unsigned char*)str;
+ auto* cp = (unsigned char*)str;
if (*cp < 0x80) {
if (bytes != nullptr) {
/* the number of frames the answer will comprise */
int frames = (cmd == dg100cmd_getfile) ? 2 : 1;
/* alias pointer for easy typecasting */
- uint8_t* buf = (uint8_t*) recvbuf;
+ auto* buf = (uint8_t*) recvbuf;
int fill = 0;
for (int i = 0; i < frames; i++) {
int n = dg100_recv(cmd, buf + fill, count - fill);
int delh = 0;
int delv = 0;
- Waypoint* waypointp = const_cast<Waypoint*>(wpt);
+ auto* waypointp = const_cast<Waypoint*>(wpt);
if ((hdopf >= 0.0) && (waypointp->hdop > hdopf)) {
delh = 1;
int ct = waypt_count();
- wpt_ptr* htable = (wpt_ptr*) xmalloc(ct * sizeof(*htable));
+ auto* htable = (wpt_ptr*) xmalloc(ct * sizeof(wpt_ptr));
wpt_ptr* bh = htable;
int i = 0;
return nullptr;
}
- mag_info* info = (mag_info*) xmalloc(sizeof(mag_info));
+ auto* info = (mag_info*) xmalloc(sizeof(mag_info));
info->geo_path = nullptr;
info->track_path = nullptr;
info->waypoint_path = nullptr;
foreach (Waypoint* wpt, data->waypt_list) {
if (wpt->extra_data) {
- gpi_waypt_t* dt = (gpi_waypt_t*) wpt->extra_data;
+ auto* dt = (gpi_waypt_t*) wpt->extra_data;
delete dt;
}
delete wpt;
foreach (const Waypoint* wpt, data->waypt_list) {
int s1;
- gpi_waypt_t* dt = (gpi_waypt_t*) wpt->extra_data;
+ auto* dt = (gpi_waypt_t*) wpt->extra_data;
QString str = wpt->description;
if (str.isEmpty()) {
LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 3];
LatLW = LatLW << 8;
LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 2];
- double LatF = (double)LatLW;
+ auto LatF = (double)LatLW;
if (LatF > 8388608) {
LatF = LatF - 16777216;
}
LonLW = LonLW+TrackBlock[(ii-1)*12+6];
LonLW = LonLW << 8;
LonLW = LonLW+TrackBlock[(ii-1)*12+5];
- double LonF = (double)LonLW;
+ auto LonF = (double)LonLW;
if (LonF>8388608) {
LonF = LonF - 16777216;
}
gbfile*
gbfopen(const QString& filename, const char* mode, const char* module)
{
- gbfile* file = (gbfile*) xcalloc(1, sizeof(*file));
+ auto* file = (gbfile*) xcalloc(1, sizeof(gbfile));
file->module = xstrdup(module);
file->mode = 'r'; // default
gbfile* gbfopen(const QString& filename, const char* mode, const char* module);
gbfile* gbfopen_be(const QString& filename, const char* mode, const char* module);
-#define gbfopen_le gbfopen
+inline gbfile* gbfopen_le(const QString& filename, const char* mode, const char* module)
+{
+ return gbfopen(filename, mode, module);
+}
void gbfclose(gbfile* file);
gbsize_t gbfread(void* buf, gbsize_t size, gbsize_t members, gbfile* file);
int gbfungetc(int c, gbfile* file);
int32_t gbfgetint32(gbfile* file);
-#define gbfgetuint32 (uint32_t)gbfgetint32
+inline uint32_t gbfgetuint32(gbfile* file)
+{
+ return gbfgetint32(file);
+}
int16_t gbfgetint16(gbfile* file);
-#define gbfgetuint16 (uint16_t)gbfgetint16
+inline uint16_t gbfgetuint16(gbfile* file)
+{
+ return gbfgetint16(file);
+}
double gbfgetdbl(gbfile* file); // read a double value
float gbfgetflt(gbfile* file); // read a float value
char* gbfgetstr(gbfile* file); // read until any type of line-breaks or EOF
char* gbfgetcstr_old(gbfile* file); // read a null terminated string
int gbfputint16(int16_t i, gbfile* file);
-#define gbfputuint16(a,b) gbfputint16((uint16_t)(a),(b))
+inline int gbfputuint16(uint16_t i, gbfile* file)
+{
+ return gbfputint16(i, file);
+}
int gbfputint32(int32_t i, gbfile* file);
-#define gbfputuint32(a,b) gbfputint32((uint32_t)(a),(b))
+inline int gbfputuint32(uint32_t i, gbfile* file)
+{
+ return gbfputint32(i, file);
+}
int gbfputdbl(double d, gbfile* file); // write a double value
int gbfputflt(float f, gbfile* file); // write a float value
/* Wrapper to safely cast a void * into a gbser_handle */
static gbser_handle* gbser__get_handle(void* p)
{
- gbser_handle* h = (gbser_handle*) p;
+ auto* h = (gbser_handle*) p;
assert(h->magic == MYMAGIC);
return h;
}
{
gbser_handle* h = gbser__get_handle(handle);
unsigned count = *len;
- unsigned char* cp = (unsigned char*) *buf;
+ auto* cp = (unsigned char*) *buf;
if (count > h->inbuf_used) {
count = h->inbuf_used;
}
qPrintable(wpt->shortname), wpt_class, links);
#endif
for (int j = 0; j < links; j++) {
- garmin_ilink_t* il_step = (garmin_ilink_t*) xmalloc(sizeof(*il_step));
+ auto* il_step = (garmin_ilink_t*) xmalloc(sizeof(garmin_ilink_t));
il_step->ref_count = 1;
break;
}
- signed char* buf = (signed char*) xmalloc(bufsz);
+ auto* buf = (signed char*) xmalloc(bufsz);
while ((len = gbfread(buf, 1, bufsz, fin))) {
struct tm tm;
printf("len=%d Payload:", length);
}
- uint8_t* payload = (uint8_t*) malloc(length);
+ auto* payload = (uint8_t*) malloc(length);
if (payload == nullptr) {
goto error_out;
}
static double
read_altitude(void* ptr)
{
- unsigned char* i = (unsigned char*) ptr;
+ auto* i = (unsigned char*) ptr;
char buf[sizeof(float)];
le_write32(&buf, i[2] << 24 | i[1] << 16 | i[0] <<8 | i[3]);
return le_read_float(&buf);
write_altitude(void* ptr, const float alt)
{
char buf[sizeof(float)];
- unsigned char* i = (unsigned char*) &buf;
+ auto* i = (unsigned char*) &buf;
le_write_float(&buf, alt);
le_write32(ptr, i[0] << 24 | i[3] << 16 | i[2] << 8 | i[1]);
}
memset(&tm, 0, sizeof(tm));
- unsigned char* HxWpt = (unsigned char*) xcalloc(GM100_WPO_FILE_SIZE, 1);
+ auto* HxWpt = (unsigned char*) xcalloc(GM100_WPO_FILE_SIZE, 1);
/* read the wpo file to the data-array */
int iDataRead = gbfread(HxWpt, 1, GM100_WPO_FILE_SIZE, file_in);
/* num_points is actually one too big, because it includes the value in
the header. But we want the extra point at the end because the
freak-value filter below looks at points[i+1] */
- humminbird_trk_point_t* points = (humminbird_trk_point_t*) xcalloc(th.num_points, sizeof(humminbird_trk_point_t));
+ auto* points = (humminbird_trk_point_t*) xcalloc(th.num_points, sizeof(humminbird_trk_point_t));
if (! gbfread(points, sizeof(humminbird_trk_point_t), th.num_points-1, fin)) {
fatal(MYNAME ": Unexpected end of file reading points!\n");
}
/* num_points is actually one too big, because it includes the value in
the header. But we want the extra point at the end because the
freak-value filter below looks at points[i+1] */
- humminbird_trk_point_old_t* points = (humminbird_trk_point_old_t*)xcalloc(th.num_points, sizeof(humminbird_trk_point_old_t));
+ auto* points = (humminbird_trk_point_old_t*)xcalloc(th.num_points, sizeof(humminbird_trk_point_old_t));
if (! gbfread(points, sizeof(humminbird_trk_point_old_t), th.num_points-1, fin)) {
fatal(MYNAME ": Unexpected end of file reading points!\n");
}
{
char header[IGO8_HEADER_SIZE] = {};
igo8_id_block tmp_id_block;
- p_igo8_id_block id_block = (p_igo8_id_block)header;
+ auto id_block = (p_igo8_id_block)header;
uint32_t current_position = 0;
const char* title = "Title";
const char* description = "Description";
void
Diag(void* buf, size_t sz)
{
- unsigned char* cbuf = (unsigned char*) buf;
+ auto* cbuf = (unsigned char*) buf;
while (sz--) {
GPS_Diag("%02x ", *cbuf++);
}
void
DiagS(void* buf, size_t sz)
{
- unsigned char* cbuf = (unsigned char*) buf;
+ auto* cbuf = (unsigned char*) buf;
while (sz--) {
unsigned char c = *cbuf++;
struct termios tty;
if (global_opts.debug_level >= 2) fprintf(stderr, "GPS Serial Open at %d\n", gps_baud_rate);
speed_t baud = mkspeed(gps_baud_rate);
- posix_serial_data* psd = (posix_serial_data*)dh;
+ auto* psd = (posix_serial_data*)dh;
/*
* This originally had O_NDELAY | O_NOCTTY in here, but this
int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size)
{
- posix_serial_data* psd = (posix_serial_data*)dh;
+ auto* psd = (posix_serial_data*)dh;
#if GARMULATOR
static int l;
static char* rp;
int32 GPS_Serial_Write(gpsdevh* dh, const void* obuf, int size)
{
- posix_serial_data* psd = (posix_serial_data*)dh;
+ auto* psd = (posix_serial_data*)dh;
return write(psd->fd, obuf, size);
}
************************************************************************/
int32 GPS_Serial_Flush(gpsdevh* fd)
{
- posix_serial_data* psd = (posix_serial_data*)fd;
+ auto* psd = (posix_serial_data*)fd;
if (tcflush(psd->fd,TCIOFLUSH)) {
GPS_Serial_Error("SERIAL: tcflush error");
int32 GPS_Serial_Close(gpsdevh* fd)
{
- posix_serial_data* psd = (posix_serial_data*)fd;
+ auto* psd = (posix_serial_data*)fd;
if (tcsetattr(psd->fd, TCSAFLUSH, &psd->gps_ttysave)==-1) {
gps_errno = HARDWARE_ERROR;
{
fd_set rec;
struct timeval t;
- posix_serial_data* psd = (posix_serial_data*)dh;
+ auto* psd = (posix_serial_data*)dh;
int32 fd = psd->fd;
#if GARMULATOR
{
fd_set rec;
struct timeval t;
- posix_serial_data* psd = (posix_serial_data*)dh;
+ auto* psd = (posix_serial_data*)dh;
FD_ZERO(&rec);
FD_SET(psd->fd,&rec);
int32 GPS_Serial_On(const char* port, gpsdevh** dh)
{
- posix_serial_data* psd = (posix_serial_data*) xcalloc(sizeof(posix_serial_data), 1);
+ auto* psd = (posix_serial_data*) xcalloc(sizeof(posix_serial_data), 1);
*dh = (gpsdevh*) psd;
if (!GPS_Serial_Open((gpsdevh*) psd,port)) {
QThread::usleep(100000);
// Change port speed
- posix_serial_data* psd = (posix_serial_data*)fd;
+ auto* psd = (posix_serial_data*)fd;
tty = psd->gps_ttysave;
cfsetospeed(&tty,speed);
gusb_cmd_get(garmin_usb_packet* ibuf, size_t sz)
{
int rv;
- unsigned char* buf = (unsigned char*) &ibuf->dbuf;
+ auto* buf = (unsigned char*) &ibuf->dbuf;
unsigned short pkt_id;
top:
switch (receive_state) {
{
unsigned int rv, i;
- unsigned char* obuf = (unsigned char*) &opkt->dbuf;
+ auto* obuf = (unsigned char*) &opkt->dbuf;
const char* m1, *m2;
rv = gusb_llops->llop_send(opkt, sz);
{
QString r;
- fs_xml* fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
+ auto* fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
if (!fs_gpx) {
return r;
lowranceusr4_fsdata*
lowranceusr4_alloc_fsdata()
{
- lowranceusr4_fsdata* fsdata = (lowranceusr4_fsdata*) xcalloc(sizeof(*fsdata), 1);
+ auto* fsdata = (lowranceusr4_fsdata*) xcalloc(1, sizeof(lowranceusr4_fsdata));
fsdata->fs.type = FS_LOWRANCEUSR4;
fsdata->fs.copy = (fs_copy) lowranceusr4_copy_fsdata;
fsdata->fs.destroy = lowranceusr4_free_fsdata;
static void
lowranceusr4_waypt_disp(const Waypoint* wpt)
{
- lowranceusr4_fsdata* fs = (lowranceusr4_fsdata*) fs_chain_find(wpt->fs, FS_LOWRANCEUSR4);
+ auto* fs = (lowranceusr4_fsdata*) fs_chain_find(wpt->fs, FS_LOWRANCEUSR4);
/* UID unit number */
if (opt_serialnum_i > 0) {
gbfputint32(text_len, file_out);
gbfwrite(CSTR(name), 1, text_len, file_out);
- short num_trail_points = (short) trk->rte_waypt_ct;
+ auto num_trail_points = (short) trk->rte_waypt_ct;
short max_trail_size = MAX_TRAIL_POINTS;
if (num_trail_points > max_trail_size) {
num_trail_points = max_trail_size;
gbfputs(name, file_out);
/* num legs */
- short num_legs = (short) rte->rte_waypt_ct;
+ auto num_legs = (short) rte->rte_waypt_ct;
gbfputint16(num_legs, file_out);
char route_reversed=0;
gbfwrite(&route_reversed, 1, 1, file_out);
route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct);
}
- lowranceusr4_fsdata* fs = (lowranceusr4_fsdata*) fs_chain_find(rte->fs, FS_LOWRANCEUSR4);
+ auto* fs = (lowranceusr4_fsdata*) fs_chain_find(rte->fs, FS_LOWRANCEUSR4);
/* UID unit number */
if (opt_serialnum_i > 0) {
for (int i = 0; i < waypt_table_ct; i++) {
const Waypoint* cmp = waypt_table[i];
if (cmp->shortname == wpt->shortname) {
- lowranceusr4_fsdata* fs = (lowranceusr4_fsdata*) fs_chain_find(cmp->fs, FS_LOWRANCEUSR4);
+ auto* fs = (lowranceusr4_fsdata*) fs_chain_find(cmp->fs, FS_LOWRANCEUSR4);
if (opt_serialnum_i > 0) {
gbfputint32(opt_serialnum_i, file_out); // use option serial number if specified
add_to_hashlist(mkshort_handle_imp* h, char* name)
{
int hash = hash_string(name);
- uniq_shortname* s = (uniq_shortname*) xcalloc(1, sizeof(uniq_shortname));
+ auto* s = (uniq_shortname*) xcalloc(1, sizeof(uniq_shortname));
s->orig_shortname = xstrdup(name);
h->namelist[hash].append(s);
void
mkshort_del_handle(short_handle* h)
{
- mkshort_handle_imp* hdr = (mkshort_handle_imp*) *h;
+ auto* hdr = (mkshort_handle_imp*) *h;
if (!h || !hdr) {
return;
void
setshort_length(short_handle h, int l)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
if (l == 0) {
hdl->target_len = default_target_len;
} else {
void
setshort_whitespace_ok(short_handle h, int l)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
hdl->whitespaceok = l;
}
void
setshort_repeating_whitespace_ok(short_handle h, int l)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
hdl->repeating_whitespaceok = l;
}
void
setshort_defname(short_handle h, const char* s)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
if (s == nullptr) {
fatal("setshort_defname called without a valid name.");
}
void
setshort_badchars(short_handle h, const char* s)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
if ((hdl->badchars != nullptr)) {
xfree(hdl->badchars);
void
setshort_goodchars(short_handle h, const char* s)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
if (hdl->goodchars != nullptr) {
xfree(hdl->goodchars);
void
setshort_mustupper(short_handle h, int i)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
hdl->mustupper = i;
}
void
setshort_mustuniq(short_handle h, int i)
{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
hdl->must_uniq = i;
}
char* tstring;
char* cp;
int i, l, replaced;
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
+ auto* hdl = (mkshort_handle_imp*) h;
if (is_utf8) {
ostring = cet_utf8_strdup(istring); /* clean UTF-8 string */
static mmo_data_t*
mmo_register_object(const int objid, const void* ptr, const gpsdata_type type)
{
- mmo_data_t* data = (mmo_data_t*) xcalloc(1, sizeof(*data));
+ auto* data = (mmo_data_t*) xcalloc(1, sizeof(mmo_data_t));
data->data = const_cast<void*>(ptr);
data->visible = 1;
data->locked = 0;
#ifdef MMO_DBG
const char* sobj = "CObjRoute";
#endif
- route_head* rte = (route_head*) data->data;
+ auto* rte = (route_head*) data->data;
char buf[7];
if (mmo_version >= 0x12) {
static void
mmo_finalize_rtept_cb(const Waypoint* wptref)
{
- Waypoint* wpt = const_cast<Waypoint*>(wptref);
+ auto* wpt = const_cast<Waypoint*>(wptref);
if ((wpt->shortname[0] == 1) && (wpt->latitude == 0) && (wpt->longitude == 0)) {
mmo_data_t* data;
{
double lat, lon;
- double east = (double) WPNC.wp_data.East;
- double north = (double) WPNC.wp_data.North;
- double alt = (double) WPNC.wp_data.Alt;
+ auto east = (double) WPNC.wp_data.East;
+ auto north = (double) WPNC.wp_data.North;
+ auto alt = (double) WPNC.wp_data.Alt;
GPS_Math_ICS_EN_To_WGS84(east, north, &lat, &lon);
wpt->latitude = lat;
static void
write_packet(unsigned type, const void* payload, unsigned length)
{
- unsigned char* packet = (unsigned char*) xmalloc(length + 9);
+ auto* packet = (unsigned char*) xmalloc(length + 9);
packet[0] = 0xa0;
packet[1] = 0xa2;
fatal(MYNAME ": Protocol error: Packet too short\n");
}
- unsigned char* data = (unsigned char*) xmalloc(size);
+ auto* data = (unsigned char*) xmalloc(size);
if (gbser_read_wait(serial_handle, data, size, SERIAL_TIMEOUT) != size) {
fatal(MYNAME ": Read error reading %d byte payload\n", size);
write_packet(PID_QRY_WAYPOINTS, payload, sizeof(payload));
- unsigned char* waypoints = (unsigned char*) xmalloc(count * 32);
+ auto* waypoints = (unsigned char*) xmalloc(count * 32);
read_packet(PID_DATA, waypoints, count * 32, count * 32, false);
write_packet(PID_READ_TRACKPOINTS, payload, sizeof(payload));
- unsigned char* trackpoints = (unsigned char*) xmalloc(count * 32);
+ auto* trackpoints = (unsigned char*) xmalloc(count * 32);
read_packet(PID_DATA, trackpoints, count * 32, count * 32, false);
write_packet(PID_ACK, nullptr, 0);
}
unsigned src = (route_id_ptr + MAX_SUBROUTE_LENGTH) / MAX_SUBROUTE_LENGTH;
- unsigned char* data = (unsigned char*) xmalloc(32 + src * 32);
+ auto* data = (unsigned char*) xmalloc(32 + src * 32);
le_write16(data + 0, 0x2000);
data[2] = 0;
int ct = waypt_list->count(), serial = 0;
unsigned long last_crc;
- htable_t* htable = (htable_t*) xmalloc(ct * sizeof *htable);
+ auto* htable = (htable_t*) xmalloc(ct * sizeof(htable_t));
htable_t* bh = htable;
int i = 0;
osm_release_ids(const Waypoint* wpt)
{
if (wpt && wpt->extra_data) {
- Waypoint* tmp = const_cast<Waypoint*>(wpt);
+ auto* tmp = const_cast<Waypoint*>(wpt);
xfree(tmp->extra_data);
tmp->extra_data = nullptr;
}
ozi_fsdata*
ozi_alloc_fsdata()
{
- ozi_fsdata* fsdata = (ozi_fsdata*) xcalloc(sizeof(*fsdata), 1);
+ auto* fsdata = (ozi_fsdata*) xcalloc(1, sizeof(ozi_fsdata));
fsdata->fs.type = FS_OZI;
fsdata->fs.copy = (fs_copy) ozi_copy_fsdata;
fsdata->fs.destroy = ozi_free_fsdata;
int faked_fsdata = 0;
int icon = 0;
- ozi_fsdata* fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
+ auto* fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
if (!fs) {
fs = ozi_alloc_fsdata();
{
const Waypoint* x1 = *(Waypoint**)a;
const Waypoint* x2 = *(Waypoint**)b;
- extra_data* x1e = (extra_data*) x1->extra_data;
- extra_data* x2e = (extra_data*) x2->extra_data;
+ auto* x1e = (extra_data*) x1->extra_data;
+ auto* x2e = (extra_data*) x2->extra_data;
if (x1e->distance > x2e->distance) {
return 1;
continue;
}
- extra_data* ed = (extra_data*) xcalloc(1, sizeof(*ed));
+ auto* ed = (extra_data*) xcalloc(1, sizeof(extra_data));
ed->distance = dist;
waypointp->extra_data = ed;
}
static void
register_waypt(const Waypoint* ref, const char)
{
- Waypoint* wpt = const_cast<Waypoint*>(ref);
+ auto* wpt = const_cast<Waypoint*>(ref);
for (int i = 0; i < waypt_table_ct; i++) {
Waypoint* cmp = waypt_table[i];
{
/* Cast away const-ness */
- Waypoint* wpp = const_cast<Waypoint*>(waypointp);
+ auto* wpp = const_cast<Waypoint*>(waypointp);
int curr_new_trkseg = waypointp->wpt_flags.new_trkseg;
wpp->wpt_flags.new_trkseg = prev_new_trkseg;
static unsigned char*
ReadRecord(gbfile* f, gbsize_t size)
{
- unsigned char* result = (unsigned char*) xmalloc(size);
+ auto* result = (unsigned char*) xmalloc(size);
(void)gbfread(result, size, 1, f);
return result;
size_t data_size = size + 4;
/* data_size can be up to about 64k */
- unsigned char* data = (unsigned char*) xmalloc(data_size);
+ auto* data = (unsigned char*) xmalloc(data_size);
if (gbfread(data, data_size, 1, file_handle) != 1) {
fatal(MYNAME ": Format error: could not read %d bytes.\n",
}
}
- uint8_t* buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6);
+ auto* buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6);
// m.ad/090930: removed code that tried reducing read_at_once if necessary since doesn't work with xmalloc
if (opt_dump_file) {
int opt_last_sector_val = atoi(opt_last_sector);
state_init(&st);
- uint8_t* buffer = (uint8_t*) xmalloc(SECTOR_SIZE);
+ auto* buffer = (uint8_t*) xmalloc(SECTOR_SIZE);
if (opt_first_sector_val > 0) {
db(4, MYNAME ": Seeking to first-sector index %i\n", opt_first_sector_val*SECTOR_SIZE);
{
QString result(len, Qt::Uninitialized);
QChar* uc = result.data();
- const unsigned char* c = (const unsigned char*)chars;
+ const auto* c = (const unsigned char*)chars;
int invalid = 0;
for (int i = 0; i < len; i++) {
QByteArray UsAsciiCodec::convertFromUnicode(const QChar* uc, int len, ConverterState* state) const
{
QByteArray result(len, Qt::Uninitialized);
- unsigned char* c = (unsigned char*)result.data();
+ auto* c = (unsigned char*)result.data();
const char replacement = (state && state->flags & ConvertInvalidToNull) ? 0 : '?';
int invalid = 0;
void SwapDataFilter::swapdata_cb(const Waypoint* ref)
{
- Waypoint* wpt = const_cast<Waypoint*>(ref);
+ auto* wpt = const_cast<Waypoint*>(ref);
double x = wpt->latitude;
wpt->latitude = wpt->longitude;
int
compare_lat(const void* a, const void* b)
{
- const struct hdr* wa = (const struct hdr*) a;
- const struct hdr* wb = (const struct hdr*) b;
+ const auto* wa = (const struct hdr*) a;
+ const auto* wb = (const struct hdr*) b;
double difference = wa->wpt->latitude - wb->wpt->latitude;
if (difference < 0) {
int
compare_lon(const void* a, const void* b)
{
- const struct hdr* wa = (const struct hdr*)a;
- const struct hdr* wb = (const struct hdr*)b;
+ const auto* wa = (const struct hdr*)a;
+ const auto* wb = (const struct hdr*)b;
double difference = wa->wpt->longitude - wb->wpt->longitude;
if (difference < 0) {
compute_blocks(struct hdr* start, int count,
double minlon, double maxlon, double minlat, double maxlat)
{
- struct blockheader* newblock = (struct blockheader*)xcalloc(sizeof(*newblock), 1);
+ auto* newblock = (struct blockheader*)xcalloc(1, sizeof(struct blockheader));
newblock->start = start;
newblock->count = count;
newblock->minlon = minlon;
lon *= -1.0;
/* convert meters back to feets */
- short int elev = (short int) METERS_TO_FEET(wpt->altitude);
+ auto elev = (short int) METERS_TO_FEET(wpt->altitude);
/* 1 bytes stringsize for shortname */
char c = shortname.length();
//
static int tpo_read_int()
{
- unsigned char val = (unsigned char) gbfgetc(tpo_file_in);
+ auto val = (unsigned char) gbfgetc(tpo_file_in);
switch (val) {
// proper place for the next track.
// Read the track bytes into a buffer
- unsigned char* buf = (unsigned char*) xmalloc(track_byte_count);
+ auto* buf = (unsigned char*) xmalloc(track_byte_count);
gbfread(buf, 1, track_byte_count, tpo_file_in);
int latscale = 0;
signed int
be_read32(const void* ptr)
{
- const unsigned char* i = (const unsigned char*) ptr;
+ const auto* i = (const unsigned char*) ptr;
return i[0] << 24 | i[1] << 16 | i[2] << 8 | i[3];
}
signed int
be_read16(const void* ptr)
{
- const unsigned char* i = (const unsigned char*) ptr;
+ const auto* i = (const unsigned char*) ptr;
return i[0] << 8 | i[1];
}
unsigned int
be_readu16(const void* ptr)
{
- const unsigned char* i = (const unsigned char*) ptr;
+ const auto* i = (const unsigned char*) ptr;
return i[0] << 8 | i[1];
}
void
be_write16(void* ptr, const unsigned value)
{
- unsigned char* p = (unsigned char*) ptr;
+ auto* p = (unsigned char*) ptr;
p[0] = value >> 8;
p[1] = value;
}
void
be_write32(void* ptr, const unsigned value)
{
- unsigned char* p = (unsigned char*) ptr;
+ auto* p = (unsigned char*) ptr;
p[0] = value >> 24;
p[1] = value >> 16;
signed int
le_read16(const void* ptr)
{
- const unsigned char* p = (const unsigned char*) ptr;
+ const auto* p = (const unsigned char*) ptr;
return p[0] | (p[1] << 8);
}
unsigned int
le_readu16(const void* ptr)
{
- const unsigned char* p = (const unsigned char*) ptr;
+ const auto* p = (const unsigned char*) ptr;
return p[0] | (p[1] << 8);
}
signed int
le_read32(const void* ptr)
{
- const unsigned char* p = (const unsigned char*) ptr;
+ const auto* p = (const unsigned char*) ptr;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
unsigned int
le_readu32(const void* ptr)
{
- const unsigned char* p = (const unsigned char*) ptr;
+ const auto* p = (const unsigned char*) ptr;
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
void
le_write16(void* ptr, const unsigned value)
{
- unsigned char* p = (unsigned char*) ptr;
+ auto* p = (unsigned char*) ptr;
p[0] = value;
p[1] = value >> 8;
}
void
le_write32(void* ptr, const unsigned value)
{
- unsigned char* p = (unsigned char*) ptr;
+ auto* p = (unsigned char*) ptr;
p[0] = value;
p[1] = value >> 8;
p[2] = value >> 16;
/* Magellan and PCX formats use this DDMM.mm format */
double ddmm2degrees(double pcx_val)
{
- signed int deg = (signed int)(pcx_val / 100.0);
+ auto deg = (signed int)(pcx_val / 100.0);
double minutes = (((pcx_val / 100.0) - deg) * 100.0) / 60.0;
return (double) deg + minutes;
}
double degrees2ddmm(double deg_val)
{
- signed int deg = (signed int) deg_val;
+ auto deg = (signed int) deg_val;
return (deg * 100.0) + ((deg_val - deg) * 60.0);
}
*/
void gb_setbit(void* buf, const uint32_t nr)
{
- unsigned char* bytes = (unsigned char*) buf;
+ auto* bytes = (unsigned char*) buf;
bytes[nr / 8] |= (1 << (nr % 8));
}
*/
char gb_getbit(const void* buf, const uint32_t nr)
{
- const unsigned char* bytes = (const unsigned char*) buf;
+ const auto* bytes = (const unsigned char*) buf;
return (bytes[nr / 8] & (1 << (nr % 8)));
}
static unsigned char*
ReadRecord(gbfile* f, gbsize_t size)
{
- unsigned char* result = (unsigned char*) xmalloc(size);
+ auto* result = (unsigned char*) xmalloc(size);
gbfread(result, size, 1, f);
return result;
double seconds =0;
++count;
- unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
+ auto* workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
WriteDouble(&workbuffer[position], RAD(waypointp->latitude));
position += sizeof(double);
static void
vitosmt_write()
{
- unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
+ auto* workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
count = 0;
{
size_t sz = amt + sizeof(struct buf_chunk);
- struct buf_chunk* c = (struct buf_chunk*) xmalloc(sz);
+ auto* c = (struct buf_chunk*) xmalloc(sz);
c->next = nullptr;
c->size = amt;
c->used = 0;
static void buf_update_checksum(struct buf_head* h, const void* data, size_t len)
{
- unsigned char* cp = (unsigned char*) data;
+ auto* cp = (unsigned char*) data;
db(4, "Updating checksum with %p, %lu, before: %02x ",
data, (unsigned long) len, h->checksum);
double lat = (double)((int32_t) le_read32(bp + 6)) / 10000000;
double lon = (double)((int32_t) le_read32(bp + 10)) / 10000000;
- double alt = (double)((int16_t) le_read16(bp + 14));
+ auto alt = (double)((int16_t) le_read16(bp + 14));
time_t rtim = decode_date(tim);
static void
fs_xml_destroy(void* fs)
{
- fs_xml* xml = (fs_xml*)fs;
+ auto* xml = (fs_xml*)fs;
if (xml) {
free_xml_tag(xml->tag);
}
static void
fs_xml_copy(void** copy, void* source)
{
- fs_xml* src = (fs_xml*)source;
+ auto* src = (fs_xml*)source;
if (!source) {
*copy = nullptr;
return;